package com.linkhub.oms.admin.modules.product.excel.listener;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.linkhub.oms.admin.modules.product.excel.dto.PackagingMaterialExcelDataDTO;
import com.linkhub.oms.common.enums.IEnumConvert;
import com.linkhub.oms.common.enums.product.LocalProductPackingMaterialTypeEnum;
import com.linkhub.oms.common.util.QtOptionalUtil;

import java.util.List;

/**
 * @Description: PackagingMaterialExcelDataListener
 * @Author: echo
 * @Date: 2024/5/12 20:12
 * @Version: 1.0
 */
public class PackagingMaterialExcelDataListener extends BaseLocalProductExcelDataListener<PackagingMaterialExcelDataDTO> {
    public PackagingMaterialExcelDataListener(List<PackagingMaterialExcelDataDTO> list) {
        super(list);
    }

    public PackagingMaterialExcelDataListener() {
        this(Lists.newArrayList());
        super.inValidDataList = Lists.newArrayList();
        super.skuSets = Sets.newHashSet();
        super.upcSets = Sets.newHashSet();
        super.fnskuSets = Sets.newHashSet();
        super.otherCodeSets = Sets.newHashSet();
    }

    @Override
    protected PackagingMaterialExcelDataDTO convertCellData(PackagingMaterialExcelDataDTO data) {
        LocalProductPackingMaterialTypeEnum materialType = IEnumConvert.valueOf(data.getPackingMaterialType(),
                LocalProductPackingMaterialTypeEnum.class);

        QtOptionalUtil.of(materialType)
                .map(LocalProductPackingMaterialTypeEnum::getIsRecordStock)
                .ifPresent(data::setIsRecordStock);

        return data;
    }

    @Override
    protected String getSku(PackagingMaterialExcelDataDTO data) {
        return data.getSku();
    }

    @Override
    protected String getUpc(PackagingMaterialExcelDataDTO data) {
        return data.getUpc();
    }

    @Override
    protected String getFnsku(PackagingMaterialExcelDataDTO data) {
        return data.getFnsku();
    }

    @Override
    protected String getOtherCode(PackagingMaterialExcelDataDTO data) {
        return data.getOtherCode();
    }
}
